import store from '../store/index.js'
const install = (Vue, vm) => {
	Vue.prototype.$u.http.setConfig({
		baseUrl: '/api',
		loadingText: '努力加载中~',
		originalData: true,
	});
	Vue.prototype.$u.http.interceptor.request = (config) => {
		 if(config.url == "/teacher/task/saveUserEvaluate"){
			config.header = { 'content-type': 'application/json', }
		} else{
			config.header = { 'content-type': 'application/x-www-form-urlencoded', }
		}
		config.header.Authorization = store.state.token!=null?store.state.token+"="+(new Date()).getTime():(new Date()).getTime()
		return config;
	}
	Vue.prototype.$u.http.interceptor.response = (res) => {
		switch (res.statusCode) {
			case 200:
				return res;
				break;
			default:
				vm.$u.toast('失败了');
				return false;
				break;
		}
	}
}

export default {
	install
}
